package main

import (
	"fmt"
	"os"
	"os/exec"
)

/*
cd src/base_pkg/cmd
go run cmdTest.go
*/
func main() {
	// 执行文件
	cmd := exec.Command("sh", "xxx.sh")
	cmd.Dir = "./"
	cmd.Env = []string{"hello=你好"}
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err := cmd.Run()
	fmt.Println("run err:", err)

	// 执行命令
	cmd = exec.Command("sh", "-c", "echo hello")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	err = cmd.Run()
	fmt.Println("run err:", err)
}
